#!/bin/bash
echo ""
echo "Welcome to CloudDoor Installer."

sudo apt-get install wpasupplicant

echo "auto eth0" >> /etc/network/interfaces
echo "iface eth0 inet dhcp" >> /etc/network/interfaces
echo "auto wlan0" >> /etc/network/interfaces
echo "iface wlan0 inet dhcp" >> /etc/network/interfaces
echo "wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf" >> /etc/network/interfaces
chmod 755 /etc/network/interfaces
chmod 755 /etc/wpa_supplicant

sudo touch /usr/local/bin/door-start
sudo chmod -R 777 /usr/local/bin/door-start
echo "cd $PWD" >> /usr/local/bin/door-start
echo "cp /root/CloudDoorGit/CloudDoor /root/CloudDoor/" >> /usr/local/bin/door-start
echo "cd /root/CloudDoor/" >> /usr/local/bin/door-start
echo "chmod -R 777 CloudDoor" >> /usr/local/bin/door-start
echo "./CloudDoor" >> /usr/local/bin/door-start
# echo "git clone https://gitee.com/ahnu119/CloudDoorGit.git" >> /usr/local/bin/door-start

sed -i -e '$i \/usr/local/bin/door-start\n' /etc/rc.local
sudo chmod -R 777 /usr/local/bin/door-start
